package com.ming.stringstudy.feedbacksystem.service.impl;

import com.ming.stringstudy.feedbacksystem.anno.PermissionLog;
import com.ming.stringstudy.feedbacksystem.entity.Comment;
import com.ming.stringstudy.feedbacksystem.entity.Evaluation;
import com.ming.stringstudy.feedbacksystem.mapper.CommentMapper;
import com.ming.stringstudy.feedbacksystem.mapper.EvaluationMapper;
import com.ming.stringstudy.feedbacksystem.service.IEvaluationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.stringstudy.feedbacksystem.utils.PermissionConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 评价表 服务实现类
 * </p>
 *
 * @author aming
 * @since 2024-12-24
 */
@Service
@Slf4j
public class EvaluationServiceImpl extends ServiceImpl<EvaluationMapper, Evaluation> implements IEvaluationService {
    @Autowired
    EvaluationMapper evaluationMapper;
    @Autowired
    CommentMapper commentMapper;
    @PermissionLog(PermissionConstants.EVALUATION_REPLY)
    @Override
    public void insertEavluation(Integer commentId, Evaluation evaluation) {
        evaluationMapper.insert(evaluation);
        Comment comment = new Comment();
        comment.setId(commentId);
        comment.setCommentState(Integer.valueOf("3"));
        comment.setEvaluationId(evaluation.getId());
        log.info("comment:{}", comment);
        commentMapper.updateById(comment);
    }
}
